/*
 * @Author: wwssaabb
 * @Date: 2021-06-25 15:57:04
 * @LastEditTime: 2021-06-25 17:07:00
 * @FilePath: \demo\todo_list\src\store\getters.ts
 */

import { State } from "./state";
import { GetterTree } from "vuex";

export type Getters = {
  completedCount(state: State): number;
  totalCount(state: State): number;
};

export const getters: GetterTree<State, State> & Getters = {
  completedCount(state) {
    return state.todoList.filter((i) => i.completed).length;
  },
  totalCount(state) {
    return state.todoList.length;
  },
};
